<?php
namespace core\lib;

class config{
    public static $con;
    public static function get($name,$file){
        /**
         *  判断配置文件是否存在
         *  判断配置是否存在
         *  缓存配置
         */
        $config_file = KJ.'/core/config/config.php';
        if (is_file($config_file)){
            $config = include $config_file;
            if (isset(self::$con[$file])){
                return self::$con[$file][$name];
            }else{
                if(isset($config[$file])){
                    if (isset($config[$file][$name])){
                        self::$con[$file] = $config[$file];
                        return $config[$file][$name];
                    }else{
                        throw new \Exception('没有配置项'.$name);
                    }
                }
            }
        }else{
            throw new \Exception('找不到配置文件'.$file);
        }
    }
    public static function all($file){
        $config_file = KJ.'/core/config/config.php';
        if (is_file($config_file)){
            $config = include $config_file;
            if (isset(self::$con[$file])){
                return self::$con[$file];
            }else{
                if(isset($config[$file])){
                    self::$con[$file] = $config[$file];
                    return $config[$file];
                }
            }
        }else{
            throw new \Exception('找不到配置文件'.$file);
        }
    }
}
?>